package com.my.service;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.my.domain.MyZbzj;
import com.my.mapper.MyZbzjMapper;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MyZbzjService extends ServiceImpl<MyZbzjMapper, MyZbzj> {


    public List<MyZbzj> zbjList(String name) {
        return list(new LambdaQueryWrapper<>(MyZbzj.class)
                .eq(name != null,MyZbzj::getName, name));

    }

    public void zbzjEdit(MyZbzj zbzj) {
        if (ObjectUtil.isNull(zbzj.getId())){
            save(zbzj);
            return;
        }
        updateById(zbzj);
    }

    public void zbzjDeleted(String id) {
        removeById(id);
    }
}
